﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;

/*********************************************************
 * 命名空间 Simple.Common
 * 接口名称 BaseEntity
 * 开发人员：11920
 * 创建时间：2023/5/4 10:37:46
 * 描述说明：
 * 更改历史：
 * 
 * *******************************************************/
namespace Simple.Tools
{
	/// <summary>
	/// 基础实体
	/// </summary>
	/// <typeparam name="TKey"></typeparam>
	public class BaseEntity<TKey>:IEquatable<BaseEntity<TKey>>
	{
		//[SugarColumn(IsPrimaryKey = true)]//数据库是自增才配自增 
		/// <summary>
		/// 
		/// </summary>
		public virtual TKey Id { get { return id; } set { id = value; } }
		private TKey id;
		/// <summary>
		/// 
		/// </summary>
		/// <param name="other"></param>
		/// <returns></returns>
		public bool Equals(BaseEntity<TKey>? other)
		{
			if (other==null || !other.Id.Equals(Id))
			{
				return false;
			}
			return true;
		}
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public override string ToString()
		{
			return JsonConvert.SerializeObject(this);
		}
	}
}
